package com.practice.designMode.responsibilityChain.validation;

import com.practice.designMode.responsibilityChain.exception.ValidatorException;

public class MinValidatorHandler implements ValidatorHandler{

    private final Integer min;

    public MinValidatorHandler(Integer min) {
        this.min = min;
    }

    @Override
    public void validate(Object bean,ValidatorContext validatorContext) throws ValidatorException {
        if (bean instanceof Integer integer) {
            if(integer < min){
                validatorContext.appendError(integer + " is lower than " + min + " Integer value is too small");
            }
        }
    }
}
